#ifndef __MAIN_H__
#define __MAIN_H__
const char* mqtt_server = "bemfa.com";  //默认，MQTT服务器
const int mqtt_server_port = 9501;      //默认，MQTT服务器

String aptype = "006";                                  //001插座类型，002灯类型，003风扇类型，004传感器，005空调，006开关，009窗帘
String verSion = "1";                                   //1是mqtt协议，3是tcp协议,5是mqtt V2 版本，7是 tcp V2 版本
String adminID = "";                                    //默认空即可。企业id，企业用户可配置，用户会自动绑定到该企业下，获取id方法见接入文档5.17节
bool pcState = false;                                   //led 状态

String topicMac = "";
int httpCode = 0;
String UID = "";
String TOPIC = "";
#define HOST_NAME "bemfa"
char config_flag = 0;
#define MAGIC_NUMBER 0xAA

long lastMsg = 0;
char msg[50];
int value = 0;
char buf[36];

struct config_type
{
  char stassid[32];
  char stapsw[16];
  char cuid[40];
  char ctopic[32];
  uint8_t reboot;
  uint8_t magic;
  char MACAddress[36];
};
config_type config;

#define MAGIC_NUMBER 0xAA //判断是否配网
char packetBuffer[255]; //发送数据包
uint8_t *p = (uint8_t*)(&config);

void loadConfig();
void restoreFactory();
void saveConfig();
void apConfig(String mac);
void getUid(String mac, bool reConfig);
void reconnect();



#endif
